package plan.parser.reader;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import android.util.Log;

public class Reader {
	private String[] readerElements;
	private String source="";
	
	public Reader (String in)
	{
		File plan = new File (in);
		read(plan);
	}

	private void read(File plan) {

		try {
			BufferedReader br = new BufferedReader(new FileReader(plan));
			String str="";
			while ((str = br.readLine()) != null){
				source+=str;
			}
			br.close();
			
			source=source.trim();
			//source=source.replace("><", ">xxx<");
			source=source.replace(">", ">xxx");
			source=source.replace("</", "xxx</");
			source=source.replace(">xxxxxx</", ">xxx</");
			readerElements=source.split("xxx");
		}
		catch (Exception e) {
			Log.e("MobilnaElka", e.getMessage());
		}
	}
	
	public String[] getReaderElements(){
		return readerElements;
	}
	
	public void print(String[] tokens) {
		for (int i=0;i<tokens.length;++i) {
			System.out.println(i+": ["+tokens[i]+"]");
		}
	}
	
	
}
